home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / THINK C 5.0.3 Update.cpt / THINK C 5.0.3 Update / oops.h < prev    next >
Text File  |  1992-05-10  |  2KB  |  117 lines

  1.  
  2. /*
  3.  *  oops.h
  4.  *
  5.  *  Copyright (c) 1991 Symantec Corporation.  All rights reserved.
  6.  *
  7.  */
  8.  
  9. #pragma once
  10.  
  11.  
  12. /* ---------- public interface ---------- */
  13.  
  14.  
  15.     /*  member  */
  16.  
  17. #define member(o, c)    __member(__class c, __class(o))
  18. #if __option(far_code) || __option(far_data)
  19. char __member(void *, void *);
  20. #else
  21. char __member(void *, short);
  22. #endif
  23.  
  24.  
  25.     /*  instantiation by name  */
  26.  
  27. void *new_by_name(char *);
  28. #define class_name(o)    __class_name(__class(o))
  29. char *__class_name(...);
  30.  
  31.  
  32.     /*  "__cn" - macro implementation of "class_name" (for use in debugger)  */
  33.  
  34. #if !__option(a4_globals)
  35.  
  36. #if __option(far_code) || __option(far_data)
  37.     #define __caddr(o)            __class(o)
  38.     #define __cshift            3
  39.     #define __cofs                36
  40. #else
  41.     #define __caddr(o)            (__class(o) + * (long *) 0x904)
  42.     #define __cshift            2
  43.     #define __cofs                22
  44. #endif
  45.  
  46. #define __cn(o)        &((char *) __caddr(o))[((* (short *) __caddr(o)) << __cshift) + __cofs]
  47.  
  48. #endif
  49.  
  50.  
  51.     /*  debugging hooks  */
  52.  
  53. void __noObject(void);
  54. void __noMethod(void);
  55.  
  56.  
  57. /* ---------- private interface ---------- */
  58.  
  59.  
  60. #ifdef OOPS_PRIVATE
  61.  
  62.  
  63.     /*  configuration  */
  64.  
  65. #if __option(far_code) || __option(far_data)
  66.     // no base reg
  67. #elif __option(a4_globals)
  68.     #define BASE_REG    A4
  69. #else
  70.     #define BASE_REG    A5
  71. #endif
  72.  
  73.  
  74.     /*  size of references  */
  75.  
  76. #ifdef BASE_REG
  77.     typedef short Ref;
  78.     #define _            W
  79.     #define DSHIFT        2
  80. #else
  81.     typedef void *Ref;
  82.     #define _            L
  83.     #define DSHIFT        3
  84. #endif
  85.  
  86.  
  87.     /*  dispatch table format  */
  88.  
  89. typedef struct {
  90.     Ref                method;
  91.     Ref                selector;
  92. } DispatchEntry;
  93.  
  94. typedef struct {
  95.     short            countM1;            /*  # entries - 1  */
  96.     DispatchEntry    entry[];            
  97. } DispatchTable;
  98.  
  99.  
  100.     /*  class info format  */
  101.  
  102. typedef struct {
  103.     Ref                superclass;            /*  0 for root class (MUST BE FIRST)  */
  104.     Ref                allocator;            /*  "operator new" (0 if none)  */
  105.     Ref                deallocator;        /*  "operator delete" (0 if none)  */
  106.     Ref                constructor;        /*  "X::X()" (0 if none)  */
  107.     Ref                destructor;            /*  "X::~X()" (0 if none)  */
  108.     long            size;                /*  # bytes in object of this class  */
  109.     short            dispatch;            /*  offset back to dispatch table (+1 for indirect)  */
  110.     char            name[];                /*  class name (0-terminated)  */
  111. } ClassInfo;
  112.  
  113. #define ClassInfo_(ofs)        ((int) &((ClassInfo *) 0)->ofs)
  114.  
  115.  
  116. #endif /* OOPS_PRIVATE */
  117.